<template>
    <div class="Edit">
        <el-dialog title="设置排序" v-model="props.visible" :before-close="beforeClose">
            <el-form :model="formVlue" label-width="100px">
                <el-form-item label="排序">
                    <el-input v-model='formVlue.sort'></el-input>
                </el-form-item>
            </el-form>
            <template #footer>
                <div class="dialog-footer">
                    <el-button @click="onCancel">取消</el-button>
                    <el-button type="primary" @click="onConfirm">
                        确定
                    </el-button>
                </div>
            </template>
        </el-dialog>
    </div>
</template>

<script setup lang="ts">
import { ref, defineProps, withDefaults, defineEmits, watch } from 'vue';
import type { Ref } from 'vue'
import { TjList, TjRes, Sort } from '../../../json/request/QmsAdminConreiller/index'
let props = withDefaults(
    defineProps<{
        visible: boolean;
        form: TjRes

    }>(), {
    visible: true
}
)
let formVlue = ref({}) as Ref<TjRes>
watch(
    () => props.form,
    (newVal) => {
        // console.log(newVal);
        formVlue.value = { ...newVal };
        // f.value = { ...newVal };
    }
);

// 取消
let emits = defineEmits<
    {
        (event: 'cancel'): void;
        (event: 'sure', row: Sort): void;
    }
>()
let onCancel = () => {
    // props.visible = false
    emits('cancel')
}
let beforeClose = () => {
    emits('cancel')
}
// 确定
let onConfirm = () => {
    emits('sure', formVlue.value)
}
</script>

<style scoped>
.el-dialog {
    width: 450px;
}
</style>